package com.zlsy.thread.stopthreads;

/**
 * @author zhouliang
 * @date 2020/2/26 19:27
 * @Desc 停止线程错误的方法 stop
 */
public class WrongStopThread implements Runnable {
    /**
     * 使用stop的话我们只能感知在哪个i下面线程停止了，但是不能感知i下面到哪个J的时候线程停止的，
     * 所以就存在J都领到或则只有几个领到的可能存在。
     */
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            //5个连队
            System.out.println("连队" + i + "开始领取武器");
            for (int j = 0; j < 10; j++) {
                //每个连队10个人
                System.out.println(j);
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("连队" + i + "已经领取完毕");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new WrongStopThread());
        thread.start();
        Thread.sleep(800);
        thread.stop();
    }
}
